package java_test;

public class StringComparePfc {
    public static void main(String[] args) {
        long startTime = System.currentTimeMillis();
        for (int i = 0; i < 50000; i++) {
            String st1 = "hello";
            String st2 = "hello";
        }
        long endTime = System.currentTimeMillis();
        System.out.println("通过 String 关键词创建字符串" + " : " + (endTime - startTime) + " 毫秒");

        long startTime1 = System.currentTimeMillis();
        for (int i = 0; i < 50000; i++) {
            String st1 = new String("hello");
            String st2 = new String("hello");
        }
        long endTime1 = System.currentTimeMillis();
        System.out.println("通过 String 关键词创建字符串" + " : " + (endTime1 - startTime1) + " 毫秒");
    }
}
